﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace QuickLifeHall.Facade.Utilities
{
    /// <summary>
    /// 权限控制
    /// </summary>
    public class PermissionUtility
    {
        /// <summary>
        /// 判断是否已通过Form验证的用户
        /// </summary>
        /// <param name="context">当前请求上下文</param>
        /// <param name="LoginUser">已登录的用户</param>
        /// <returns></returns>
        public static bool IsLogin(System.Web.HttpContext context, out Entity.SystemBase.User LoginUser)
        {
            LoginUser = null;

            if (context.User != null && context.User.Identity != null && context.User.Identity.IsAuthenticated)
            {
                DAL.SystemBase.User userRepository = new DAL.SystemBase.User();
                LoginUser = userRepository.GetByName(context.User.Identity.Name);
                if (LoginUser != null)
                {
                    return true;
                }
            }
            
            return false;
        }
    }
}
